<!doctype html >
<html>
<head>
    <script src="../libraries/RGraph.common.core.js" ></script>
    <script src="../libraries/RGraph.common.dynamic.js" ></script>
    <script src="../libraries/RGraph.common.tooltips.js" ></script>
    <script src="../libraries/RGraph.line.js" ></script>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
    <!--[if lt IE 9]><script src="../excanvas/excanvas.js"></script><![endif]-->
    
    <title>A "Fan" Line chart</title>
    
    <link rel="stylesheet" href="demos.css" type="text/css" media="screen" />
    
    <meta name="robots" content="noindex,nofollow" />
    <meta name="description" content="A customisation of the filled range Line chart to produce a currency Fan chart" />
     
</head>
<body>

    <h1>A "Fan" Line chart</h1>
    
    <p>
        This is an example of the filled range chart being used to create a "Fan" chart. Fan charts are used, for example, to illustrate
        growing uncertainty of future values. You can read about fan charts here: <a href="http://en.goldenmap.com/Fan_chart_(time_series)" rel="nofollow">http://en.goldenmap.com/Fan_chart_(time_series)</a>
    </p>

    <canvas id="cvs" width="600" height="250">[No canvas support]</canvas>

    <script>
        $(document).ready(function ()
        {
            
            /**
            * Starting with the February 2013 release you'll be able to chain Set() calls
            */
            var central_line_data = [10,13,15,15,24,19,18,16,17,18,12,11];
            
            var variance1 = [0,0,1,1,2,3,4,4,4,5,5,5];
            var variance2 = [0,0,1,1,3,4,5,5,5,6,6,6];
            var variance3 = [0,0,1,1,3,4,6,6,6,7,7,7];
            
            var d1 = [];
            var d2 = [];
            var d3 = [];
            var d4 = [];
            var d5 = [];
            var d6 = [];
            
            for (var i=0; i<central_line_data.length; ++i) {
                d1.push(central_line_data[i] + variance1[i]);
                d2.push(central_line_data[i] - variance1[i]);
                
                d3.push(central_line_data[i] + variance2[i]);
                d4.push(central_line_data[i] - variance2[i]);
                
                d5.push(central_line_data[i] + variance3[i]);
                d6.push(central_line_data[i] - variance3[i]);
            }

            var line1 = new RGraph.Line({
                id: 'cvs',
                data: [d5, d6],
                options: {
                    filled: {
                        self: true,
                        range: true
                    },
                    fillstyle: 'rgba(255,0,0,0.1)',
                    colors: ['rgba(0,0,0,0)'],
                    linewidth: 0,
                    ymax: 30,
                    ylabels: false,
                    noaxes: true,
                    background: {
                        grid: {
                            autofit: {
                                numvlines: 11
                            }
                        }
                    },
                    hmargin: 5,
                    tickmarks: null
                }
            }).draw()

            var line2 = new RGraph.Line({
                id: 'cvs',
                data: [d3, d4],
                options: {
                    filled: {
                        self: true,
                        range: true
                    },
                    fillstyle: 'rgba(255,0,0,0.2)',
                    colors: ['rgba(0,0,0,0)'],
                    linewidth: 0,
                    ymax: 30,
                    ylabels: false,
                    noaxes: true,
                    background: {
                        grid: {
                            autofit: {
                                numvlines: 11
                            }
                        }
                    },
                    hmargin: 5,
                    tickmarks: null
                }
            }).draw()


            var line3 = new RGraph.Line({
                id: 'cvs',
                data: [d1, d2],
                options: {
                    filled: {
                        self: true,
                        range: true
                    },
                    fillstyle: 'rgba(255,0,0,0.4)',
                    colors: ['rgba(0,0,0,0)'],
                    linewidth: 3,
                    ymax: 30,
                    ylabels: false,
                    noaxes: true,
                    background: {
                        grid: false
                    },
                    hmargin: 5,
                    tickmarks: null
                }
            }).draw()

            var line4 = new RGraph.Line({
                id: 'cvs',
                data: central_line_data,
                options: {
                    background: {
                        grid: false
                    },
                    labels: ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],
                    tooltips: ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],
                    colors: ['black'],
                    linewidth: 3,
                    ymax: 30,
                    numxticks: 11,
                    tickmarks: null,
                    hmargin: 5,
                    shadow: false
                }
            }).draw()
        })
    </script>

    <p>
        <a href="./">&laquo; Back</a>
    </p>

</body>
</html>

